#include "AsianProduct.h"
#include <numeric>

AsianProduct::AsianProduct(const PayOffBridge& payoff,double expiry,
	const std::vector<double>& lookAtTimes) 
	: m_payoff(payoff),m_expiry(expiry),m_lookAtTimes(lookAtTimes)
{

}
double AsianProduct::getExpiry() const
{
	return m_expiry;
}

std::vector<double> AsianProduct::getLookAtTimes() const
{
	return m_lookAtTimes;
}
std::vector<double> AsianProduct::getCashFlowTimes() const
{
	std::vector<double> cashFlowTimes(1);
	cashFlowTimes[0] = m_expiry;
	return cashFlowTimes;
}
int AsianProduct::getMaxNumOfCashFlows() const
{
	return 1;
}
std::vector<double> AsianProduct::getCashFlows(const std::vector<double>& spots) const
{
	double sum = std::accumulate(spots.begin(),spots.end(),0);
	double mean = sum / spots.size();
	std::vector<double> cashFlows(1);
	cashFlows[0]=mean;
	return cashFlows;
}


AsianProduct* AsianProduct::clone() const
{
	return new AsianProduct(*this);
}
